/*
 * ProductResource.h
 *
 *  Created on: 2013. 9. 11.
 *      Author: mega@gamevil.com
 */

#ifndef PRODUCTRESOURCE_H_
#define PRODUCTRESOURCE_H_

#include <map>
#include <Toolkit/Str.h>

namespace ProjectZ { namespace NResource {

class ProductData
{
public:
	struct Flyweight
	{
		Toolkit::Str<50> _ITEM_NAME;
		int _ICON;
		int _TID;
		Toolkit::Str<100> _PRODUCT_KEY;
		int _POSITION;
		int _PRICE;
		int _VC_INDEX;
		int _GIFT_VC_INDEX;
		int _DEFAULT_AMOUNT;
		int _BONUS_AMOUNT;
		int _BONUS_RATE;
		int _DISCOUNT;
		Toolkit::Str<1024> _IMG_URL;
		Toolkit::Str<1024> _EXPLAIN;
	};

public:
	typedef std::map<int, Flyweight *> PRODUCTMAP;

public:
	ProductData() {}
	virtual ~ProductData();

	bool			LoadResource(int company, int saleCode);
	bool			LoadEventResource(int company, int saleCode);
	Flyweight *		GetFly(User * pUser, int tid);
	PRODUCTMAP &	GetTree(User * pUser);

private:
	void	Clear();
	void	ClearEvent();

private:
	PRODUCTMAP clsFlyTree;
	PRODUCTMAP clsFlyEventTree;
};


class ProductResource
{
public:
	ProductResource();
	virtual ~ProductResource();

	bool LoadResource();
	ProductData::Flyweight * GetFly(User * pUser, int tid);
	ProductData * GetDataPtr(User * pUser);

private:
	ProductData * pProductAD;
	ProductData * pProductIOS;
};

} /* NResource */ } /* ProjectZ */


#endif /* PRODUCTRESOURCE_H_ */
